﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace NhJump.Persistence.Tests
{
    [TestFixture]
    public class EmptyEnumeratorFixture
    {
        [Test]
        public void GetEnumeratorMoveNext_YieldsNoResult()
        {
            var empty = new EmptyEnumerator<int>();

            foreach(var x in empty)
            {
                Assert.Fail("Enumerator should yield no results");
            }
        }

        [Test]
        public void GetEnumerator_ReturnsSameInstance()
        {
            var empty = new EmptyEnumerator<int>();

            Assert.AreEqual(empty, ((IEnumerable)empty).GetEnumerator());
        }

        [Test]
        public void IEnumerableGetEnumerator_ReturnsSameInstance()
        {
            var empty = new EmptyEnumerator<int>();

            Assert.AreEqual(empty, ((IEnumerable)empty).GetEnumerator());
        }

        [Test, ExpectedException(typeof(InvalidOperationException))]
        public void Current_ThrowsInvalidOperationException()
        {
            var empty = new EmptyEnumerator<int>();

            Assert.AreEqual(empty, empty.Current);
        }

        [Test, ExpectedException(typeof(InvalidOperationException))]
        public void IEnumeratorCurrent_ThrowsInvalidOperationException()
        {
            var empty = new EmptyEnumerator<int>();

            Assert.AreEqual(empty, ((IEnumerator)empty).Current);
        }
    }
}
